<?php $this->load->view('templates/backend/header'); ?>
<style>
    .table .new,.notice{
        font-weight: bold;
        color:#D65824;
    }
    .table-bordered{
            border-top:1px solid #ccc;
    }
    .pagination {
        display: inline-block;
        padding-left: 0;
        margin: 20px 0;
        border-radius: 4px;
      }
      .pagination>li {
        display: inline;
      }
      .pagination>li>a, .pagination>li>span {
        position: relative;
        float: left;
        padding: 6px 12px;
        margin-left: -1px;
        line-height: 1.42857143;
        color: #337ab7;
        text-decoration: none;
        background-color: #fff;
        border: 1px solid #ddd;
      }
      .time{
          width:10%;
          
      }
      #submit,#export{vertical-align: top;}
</style>
<h3><?php echo $this->lang->line('statiticsHr_list');?></h3>

<div class="filter">
    <?php
    echo form_open('/auth/statiticsHr/lists/');
    echo form_input(array('name' => 'beginTime', 'id' => 'datepicker1', 'value' => (isset($_POST['beginTime']))?$_POST['beginTime']:'','class'=>'time','placeholder'=>'Chọn ngày bắt đầu'));
    echo ' ';
    echo form_input(array('name' => 'endTime', 'id' => 'datepicker2', 'value' => (isset($_POST['endTime']))?$_POST['endTime']:'','class'=>'time','placeholder'=>'Chọn ngày kết thúc'));
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'filter', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search').'</a>','class' => 'btn btn-primary'));
    echo ' ';
    echo form_button(array('id' => 'export', 'value' => 'export', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('export').'</a>','class' => 'btn btn-danger'));
    echo form_close();
    ?>
</div>

<?php
if(!empty($lists)){
?>
<table class="table table-striped table-bordered dataTable" id="data-table" width="100%" aria-describedby="data-table_info" style="width: 100%;">
    <thead>
        <tr role="row">
            <th width="5%" class="sorting" role="columnheader" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="STT" style="width: 50px;">STT</th>
            <th width="5%" class="sorting_desc" role="columnheader" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Username" style="width: 280px;"><?php echo $this->lang->line('name');?></th>
            <th width="5%" class="sorting_desc" role="columnheader" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Username" style="width: 280px;"><?php echo $this->lang->line('sumsales');?></th>
            <th width="20%" class="sorting" role="columnheader" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Code game" style="width: 181px;"><?php echo $this->lang->line('phone_calltime').'(s)';?></th>
            <th width="20%" class="sorting" role="columnheader" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Code game" style="width: 181px;"><?php echo $this->lang->line('phone_busy');?></th>
            <th width="20%" class="sorting" role="columnheader" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Code game" style="width: 181px;"><?php echo $this->lang->line('phone_limited');?></th>
            <th width="20%" class="sorting" role="columnheader" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Code game" style="width: 181px;"><?php echo $this->lang->line('phone_callback');?></th>
            <th width="20%" class="sorting" role="columnheader" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Code game" style="width: 181px;"><?php echo $this->lang->line('phone_callok');?></th>
        </tr>
    </thead>

    <tbody role="alert" aria-live="polite" aria-relevant="all">
        <?php
        if(!empty($lists)){
            foreach($lists AS $key => $value){
                if($key%2 == 0){
                    $old = 'new';
                } else {
                    $old = 'old';
                }
                $sumsales = $value->phone_limited + $value->phone_busy + $value->callback + $value->callok;
                echo '<tr class="'.$old.'">';
                echo '<td class="">'.++$key.'</td>';
                echo '<td class="">'.$value->firstname.'</td>';
                echo '<td class="">'.$sumsales.'</td>';
                echo '<td class="">'.$value->phone_calltime.'</td>';
                echo '<td class="">'.$value->phone_busy.'</td>';
                echo '<td class="">'.$value->phone_limited.'</td>';
                echo '<td class="">'.$value->callback.'</td>';
                echo '<td class="">'.$value->callok.'</td>';
                echo '</tr>';
            }
        }
        ?>
    </tbody>
</table>
<?php
} else {
    echo 'Không tìm thấy dữ liệu!!!!';
}
$this->load->view('templates/backend/footer'); 
$this->load->view('templates/backend/datepicker'); 
?>

<script>
$("#submit").on('click',function(){
    var beginTime       = $("#datepicker1").val();
    var endTime         = $("#datepicker2").val();

    if(beginTime == "" && endTime == ""){
        alert("Vui lòng chọn ít nhất 1 thời điểm tìm kiếm");return false;
    }
});
</script>